package com.fanglei.demo.core.dto.resp;

import lombok.Data;
import lombok.Getter;

/**
 * @description
 * @auther: dengqi
 * @date: 2020-01-21
 */
@Data
public class BaseResp<T> {

    private String code;

    private String message;

    private T t;

    public BaseResp(ApiCodeEnum e) {
        this.code = e.getCode();
        this.message = e.getMessage();
    }

    public BaseResp() {
        this.code = ApiCodeEnum.SUCCESS.getCode();
        this.message = ApiCodeEnum.SUCCESS.getMessage();
    }

    @Getter
    public static enum ApiCodeEnum{
        SUCCESS("0000","成功"),
        FAIL("0001","失败：{}"),
        ERROR("0003","系统异常"),
        ;

        private String code;
        private String message;

        ApiCodeEnum(String code, String message) {
            this.code = code;
            this.message = message;
        }
    }
}
